{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 202,
   "metadata": {},
   "outputs": [],
   "source": [
    "from recognize_computer_vision_linear_model import generate_data\n",
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "image_data,image_label = generate_data()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n"
     ]
    }
   ],
   "source": [
    "print(image_label)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[0, 0, 1, 1, 0, 0],\n",
      "        [0, 1, 0, 0, 1, 0],\n",
      "        [0, 1, 0, 0, 1, 0],\n",
      "        [0, 1, 0, 0, 1, 0],\n",
      "        [0, 0, 1, 1, 0, 0],\n",
      "        [0, 0, 0, 0, 0, 0]])\n"
     ]
    }
   ],
   "source": [
    "print(image_data[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "i=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 296,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPUAAAD4CAYAAAA0L6C7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0\ndHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAJyElEQVR4nO3dzYtdhR3G8edpOiYaFSm1kjcaF1YQ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S7pS0Q/MngB5Psr/PTbYfk/SipMttH7J9R597\nNH8kul3zR6C50dv1Pe5ZJWmX7dc1/4/yziSD+DbSgFwiabft1yS9LOlPXV1ocnDf0gJwZgZ3pAZw\nZogaKIaogWKIGiiGqIFiiBoohqiBYv4HPQNNAd6tKd8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "#plt.imshow(image_data[i%10],cmap='gray')\n",
    "plt.imshow(image_data[i%10])\n",
    "\n",
    "plt.show()\n",
    "i=i+1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 提取feature的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "metadata": {},
   "outputs": [],
   "source": [
    "img=image_data[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([0, 3, 2, 2, 3, 0])\n"
     ]
    }
   ],
   "source": [
    "print(sum(img))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([1, 1, 0])\n"
     ]
    }
   ],
   "source": [
    "print(torch.sum(img[3:6,3:6],0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[0, 0, 1, 1, 0, 0],\n",
      "        [0, 1, 0, 0, 1, 0],\n",
      "        [0, 1, 0, 0, 1, 0],\n",
      "        [0, 1, 0, 0, 1, 0],\n",
      "        [0, 0, 1, 1, 0, 0],\n",
      "        [0, 0, 0, 0, 0, 0]])\n"
     ]
    }
   ],
   "source": [
    "print(img)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
